/**
 * 
 */
package com.ubo.visu.painter.node;

import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.input.MouseEvent;

/**
 * @author saludegu
 * 
 */
public abstract class ANodePainter implements INodePainter {

	/**
	 * Group contenant le dessin.
	 */
	protected Group mContainer;

	protected boolean mMooving;

	/**
	 * 
	 * Constructor
	 * 
	 */
	public ANodePainter() {
		mContainer = new Group();
		mContainer.setOnMousePressed(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				mMooving = true;
			}
		});
		mContainer.setOnMouseDragged(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				if (mMooving) {
					mContainer.setLayoutX(mContainer.getLayoutX()
							+ event.getX());
					mContainer.setLayoutY(mContainer.getLayoutY()
							+ event.getY());

				}
			}
		});
		mContainer.setOnMouseReleased(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				mMooving = false;
			}
		});
	}

	/**
	 * 
	 * @see com.ubo.visu.painter.node.INodePainter#getContent()
	 */
	public Node getContent() {
		return mContainer;
	}
}
